<template>
  <div>
    <a-button type="primary" @click="showModal">
      钉钉发送信息
    </a-button>
    <a-modal
      title="发送信息"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-textarea v-model="ModalText" rows="4" placeholder="请输入所要发送的信息内容"/>
      </a-form-item>
    </a-modal>
  </div>
</template>
<script>
  import {postAction} from '@/api/manage'
  export default {
    name:"DingdingMessage",
    data() {
      return {
        ModalText: '',
        visible: false,
        confirmLoading: false,
        professorid:[],
        url:"/sendmessage/dingding",
      };
    },
    props:{
      selectkeys02:{
        type:Array,
        default:[],
        required:false,
      }
    },
    methods: {
      showModal() {
        if (this.selectkeys02.length <= 0) {
          this.$message.warning('请选择一条记录！');
          return;
        } else {
          this.visible = true;
        }
      },
      handleOk(e) {
        for (var a = 0; a < this.selectkeys02.length; a++) {
          this.professorid.push(this.selectkeys02[a]);
        }
        console.log(this.professorid);
        let params={
          prefessorid:this.professorid,
          modalText:this.ModalText
        };
        //向后端发送axios请求
        postAction(this.url,params).then((res)=>{
          if (res.success == true){
            this.$message.success("发送成功！")
            this.professorid=[];
            this.ModalText="";
          }else {
            this.$message.error("发送失败！")
            this.professorid=[];
            this.ModalText="";
          }
        })
        this.visible = false;
      },
      handleCancel(e) {
        console.log('Clicked cancel button');
        this.visible = false;
      },
    },
  };
</script>

<style scoped>

</style>